Conversation
…G-JD-10) ``PATCH /v1/datasets/batch-tags`` is an ``async def`` route handler that called ``store.get_meta(...)`` and ``store.update_meta(...)`` synchronously inside a per-dataset loop. Those are filesystem I/O calls; running them on the FastAPI event loop blocks every other in-flight request for the duration of the batch. The async-wrap pattern (``await asyncio.to_thread(...)``) is applied elsewhere in the same file (line 142, ``generator_class.generate``) but was missed on this one route. Surfaced by the 2026-05-05 roadmap audit (``notes/ROADMAP_AUDIT_2026-05-05.md`` §4.1, BUG-JD-10). Fix --- Wrap each ``store.get_meta`` and ``store.update_meta`` call in ``await asyncio.to_thread(...)`` so the synchronous I/O runs on the default executor while the event loop stays free to service other requests. The user-visible behaviour is unchanged; only the event-loop fairness improves. Tests ----- - New regression case ``test_store_calls_run_off_event_loop`` — patches both store methods to record their executing thread, drives a 2-dataset batch through the route, and asserts every call ran on a worker thread (not the main thread). Future removal of the ``asyncio.to_thread`` wrapping fails the test with a clear "BUG-JD-10 regression" message naming the expected wrapping. - Existing 6 cases in ``TestBatchUpdateTags`` still pass; total 7 cases green. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
`PATCH /v1/datasets/batch-tags` is an `async def` route handler
that called `store.get_meta(...)` and `store.update_meta(...)`
synchronously inside a per-dataset loop. Those are filesystem I/O
calls; running them on the FastAPI event loop blocks every other
in-flight request for the duration of the batch.
Surfaced by the 2026-05-05 roadmap audit
(`notes/ROADMAP_AUDIT_2026-05-05.md` §4.1, BUG-JD-10).
Fix
Wrap each `store.get_meta` and `store.update_meta` call in
`await asyncio.to_thread(...)`. The async-wrap pattern is already
applied elsewhere in the same file (line 142, `generator_class.generate`);
this brings `batch_update_tags` in line.
User-visible behaviour unchanged — only event-loop fairness improves.
Test plan
memory_store fixture's `get_meta` / `update_meta` to record
their executing thread, drives a 2-dataset batch through the
route, and asserts every call ran on a worker thread (not the
main thread). Future removal of the `asyncio.to_thread`
wrapping fails the test with a clear "BUG-JD-10 regression"
message.
7 green.
🤖 Generated with Claude Code